﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Globalization;

namespace Excel.Expressions.Compiler
{
    internal class Number : CellExpression
    {
        private double _value;

        public Number(string text)
        {
            double value;
            if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out value))
            {
                throw new NotSupportedException("Initialization of the incorrect double value is not supported");
            }
            _value = value;
        }

        public override double Eval()
        {
            return _value;
        }

#if DEBUG
        public override string ToString()
        {
            return _value.ToString(CultureInfo.InvariantCulture.NumberFormat);
        }
#endif
    }
}
